
package com.rt.schedulenew.core.config;

import com.rt.schedulenew.ws.ScheduleServiceImpl;
import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.xml.ws.Endpoint;

@Configuration
public class WebServiceConfig {

//    @Bean
//    public ServletRegistrationBean newServlet() {
//        return new ServletRegistrationBean(new CXFServlet(), "/cxf/*");
//    }

//    @Autowired
//    @Qualifier("cxf")
//    private SpringBus bus;

    //    @Autowired
//    private ScheduleServiceImpl scheduleServiceImpl;

    @Bean(name = Bus.DEFAULT_BUS_ID)
    public SpringBus springBus() {
        return new SpringBus();
    }


    @Autowired
    private ScheduleServiceImpl scheduleServiceImpl;

//    @Bean
//    public ScheduleServiceImpl scheduleServiceImpl() {
//        return new ScheduleServiceImpl();
//    }


    @Bean
    public Endpoint endpoint() {
        EndpointImpl endpoint = new EndpointImpl(springBus(), scheduleServiceImpl);
        endpoint.publish("/service");
        return endpoint;
    }

}
